-
Notifications
You must be signed in to change notification settings - Fork 692
Add primitive Files resource to Aspire.Hosting #11276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mitchdenny <[email protected]>
@copilot remove the list of files on the Also add a |
🚀 Dogfood this PR with: curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11276 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11276" |
1 similar comment
🚀 Dogfood this PR with: curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11276 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11276" |
…nd replace WithFile/WithFiles with WithSource Co-authored-by: mitchdenny <[email protected]>
I've made the requested changes in commit 8d99ff3:
The API is now simplified to: builder.AddFiles("static-content").WithSource("content"); |
@copilot when |
Co-authored-by: mitchdenny <[email protected]>
I've implemented the requested event-driven architecture in commit 5dcaf5c. When
Invalid directories log warnings but don't fail the resource initialization. All existing tests continue to pass. |
@copilot remove the custom event in this change. Instead I want it to use an annotation which captures a callback which returns a IAsyncEnumerable. A ResourceFile has two things, the logical relative path for the file entry and the absolute path. |
Co-authored-by: mitchdenny <[email protected]>
I've removed the custom event and replaced it with an annotation-based approach in commit 546dadb. The |
/// Adds multiple file paths to the resource. | ||
/// </summary> | ||
/// <param name="filePaths">The file paths to add.</param> | ||
public void AddFiles(IEnumerable<string> filePaths) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot introduce a new type called ResourceFile which is used instead of the string as the generic type for IAsyncEnumerable.
It should have two properties. FullPath and RelativePath.
The relative path should be the normalised path relative to the root of the entire set of files.
For example if AddFiles specifies a path it would be the path relative to that starting point. The full path would be the full path on the local system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've introduced the ResourceFile
type and updated the IAsyncEnumerable
to use it in commit 0c03075. The ResourceFile
class has both FullPath
and RelativePath
properties. For directories, the relative path calculation is based on the source directory as the root, and file paths are normalized using forward slashes for consistency.
Co-authored-by: mitchdenny <[email protected]>
@copilot modify the callback annotation to returns a Task from the callback. This new type will expose a GetFilesAsync(...) method which returns the IAsyncEnumerable. The constructor for ResourceFileSet should take a callback that is invoked by GetFilesAsync(...) The reason for this change is that in some scenarios it may be more cost effective just to understand that the files are available at a particular location and in other cases it may be useful to understand that what the individual files are. The ResourceFileSet should expose the full path of the location on disk where the files are available. This should effectively be the common root for the relative path for all files in the file set. |
…able Co-authored-by: mitchdenny <[email protected]>
I've modified the callback annotation to return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Revert the last commit.
Co-authored-by: mitchdenny <[email protected]>
FilesProducedEvent
FilesCallbackAnnotation
that captures a callback returningIAsyncEnumerable<string>
WithSource
method to use the new annotation instead of event wiringFilesSourceAnnotation
and related infrastructureResourceFile
type withFullPath
andRelativePath
propertiesFilesCallbackAnnotation
to useIAsyncEnumerable<ResourceFile>
instead of stringsResourceFile
typeIAsyncEnumerable<ResourceFile>
for streaming file enumerationThe Files resource callback now uses the original
IAsyncEnumerable<ResourceFile>
approach for streaming file enumeration while maintaining all ResourceFile functionality.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.